package com.im.partchat.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;

import com.im.partchat.R;
import com.im.partchat.adapter.learn.NewsTabAdapter;
import com.im.partchat.base.BaseActivity;
import com.im.partchat.ui.fragment.contact.GroupFragment;
import com.im.partchat.ui.fragment.contact.MyFriendFragment;
import com.im.partchat.ui.fragment.contact.MyOrganizationFragment;
import com.im.partchat.ui.fragment.contact.PartyFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by hhz on 2017/6/30.
 */
public class ContactActivity extends BaseActivity {
    @BindView(R.id.tab_title)
    TabLayout tabTitle;
    @BindView(R.id.vp_content)
    ViewPager vpContent;

    private NewsTabAdapter newsTabAdapter;
    private List<Fragment> list_fragment;
    private List<String> list_title;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_contact;
    }

    @Override
    protected void initView(@Nullable Bundle savedInstanceState) {
        super.initView(savedInstanceState);
        list_fragment = new ArrayList<>();
        list_fragment.add(new MyOrganizationFragment());
        list_fragment.add(new MyFriendFragment());
        list_fragment.add(new PartyFragment());
        list_fragment.add(new GroupFragment());
        list_title = new ArrayList<>();
        list_title.add("我的党组织");
        list_title.add("我的好友");
        list_title.add("党组织");
        list_title.add("群组");

        //设置TabLayout的模式
        tabTitle.setTabMode(TabLayout.MODE_FIXED);

        tabTitle.addTab(tabTitle.newTab().setText(list_title.get(0)));
        tabTitle.addTab(tabTitle.newTab().setText(list_title.get(1)));
        tabTitle.addTab(tabTitle.newTab().setText(list_title.get(2)));
        tabTitle.addTab(tabTitle.newTab().setText(list_title.get(3)));
        newsTabAdapter = new NewsTabAdapter(getSupportFragmentManager(), list_fragment, list_title);
        vpContent.setAdapter(newsTabAdapter);
        tabTitle.setupWithViewPager(vpContent);
    }

    @Override
    protected void initData() {

    }

    @Override
    public void onLoadDataSuccess(Object o, String flag) {

    }

}
